package operation;

import data.Data;
import data.DataBase;


public class DelRegister implements IOperation {
    @Override
    public void work(DataBase dataBase) {
        System.out.println("预约信息删除！");
        System.out.print("请输入需要删除人员的身份证号：");
        String id = scanner.nextLine();
        int currentSize=dataBase.getContainSize();
        for (int i = 0; i < currentSize; i++) {
            if (dataBase.getData(i).getId().equals(id)) {
                for (int j = i; j < currentSize-1; j++) {
                    Data data = dataBase.getData(j+1);
                    dataBase.setData(j,data);
                }
                dataBase.setData(currentSize-1,null);
                dataBase.setContainSize(currentSize-1);
                System.out.println("已删除id="+id+"的预约信息！");
                return;
            }
        }
        System.out.println("未找到预约信息，请先预约！");
    }
}
